package red.social;

import android.app.Activity;
import android.app.Dialog;
import android.content.Intent;
import android.os.Bundle;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Gallery;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.Toast;
import android.view.View;
import android.view.View.OnClickListener;

public class galeriaActivity extends Activity {
    /** Called when the activity is first created. */
	private Dialog dialog;
	private Fotos catalogoFotos;
	private FotosAdapter fA;
	private RelativeLayout rL;
	Bundle parametros;
	int idusuario;
	@Override
	public void onCreate(Bundle savedInstanceState) {
	    super.onCreate(savedInstanceState);
	    setContentView(R.layout.fotos);
	    parametros = getIntent().getExtras();
		idusuario = parametros.getInt("idUsuario");
	    Gallery g = (Gallery) findViewById(R.id.gallery1);
	    fA = new FotosAdapter(this,idusuario);
	    g.setAdapter(fA);

	    rL = (RelativeLayout) findViewById(R.id.id_fondo);
	    
	    catalogoFotos = new Fotos();
	    
        final ImageButton subirFotos = (ImageButton)findViewById(R.id.imageButton1);
 
	    g.setOnItemClickListener(new OnItemClickListener() {
	        @SuppressWarnings("rawtypes")
			public void onItemClick(AdapterView parent, View v, int position, long id) {
            	
            
	        	String texto = fA.getNombre(position);
	        	
	        	String[] textoArray = texto.split("\b");
	        	
            			Toast.makeText(getApplicationContext(),texto , 3).show();
	        }
	    });
	    subirFotos.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				
				Intent actividadPrincipal = new Intent(galeriaActivity.this,CamaraView.class);    		
    			startActivity(actividadPrincipal);	
			}
		});   
	}
}